package com.xxx.rpc.sample.client;

import com.xxx.rpc.client.RpcProxy;
import com.xxx.rpc.sample.api.HelloService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class HelloClient {

    public static void main(String[] args) throws Exception {
    	ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
        context.start();
        RpcProxy rpcProxy = context.getBean(RpcProxy.class);

        
        for(Integer i=0;i<1000000000;i++){
        	try{
        		HelloService helloService = rpcProxy.create(HelloService.class);
                String result = helloService.hello("World"+i);
                System.out.println(result);
        	}catch(Exception ex){
        		ex.printStackTrace();
        	}
        	
        	try{
                HelloService helloService2 = rpcProxy.create(HelloService.class, "sample.hello2");
                String result2 = helloService2.hello("世界"+i);
                System.out.println(result2);
        	}catch(Exception ex){
        		ex.printStackTrace();
        	}
        	Thread.sleep(3000);
        }

        context.stop();
        context.close();
        System.exit(0);
    }
}
